/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package certcosa;

import Clientes.BusquedaCliente;
import Usuario.Usuarios;
import Ventas.Ventas;
import Proveedores.Proveedores;
import Productos.Productos;
import Clientes.Clientes;
import Compras.FacturaCompra;
import Productos.BuscarProducto;
import Proveedores.BusquedaProveedor;
import java.awt.Color;
import java.awt.Toolkit;
import javax.swing.JFrame;

/**
 *
 * @author alma
 * 
 * 
 * 
 * 
 * 
 */


public class Alternativa extends javax.swing.JFrame {

   
    public int opcion = 0;
    
    public Alternativa() {
        initComponents();
        panelOpciones.setVisible(false);
        setBackground(Color.BLACK);
        setSize(Toolkit.getDefaultToolkit().getScreenSize().height, Toolkit.getDefaultToolkit().getScreenSize().width);
        
    }

    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        contenedor = new javax.swing.JDesktopPane();
        panelOpciones = new javax.swing.JPanel();
        bNuevo = new javax.swing.JButton();
        bEditar = new javax.swing.JButton();
        bBusqueda = new javax.swing.JButton();
        lNombre = new javax.swing.JLabel();
        lImagen = new javax.swing.JLabel();
        jToolBar1 = new javax.swing.JToolBar();
        jPanel1 = new javax.swing.JPanel();
        bClientes = new javax.swing.JButton();
        bProv = new javax.swing.JButton();
        bVentas = new javax.swing.JButton();
        bProductos = new javax.swing.JButton();
        bUsuario = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Principal");
        setBackground(new java.awt.Color(0, 0, 0));
        setFont(new java.awt.Font("Serif", 0, 12)); // NOI18N

        contenedor.setBackground(new java.awt.Color(0, 0, 0));
        contenedor.setOpaque(false);

        panelOpciones.setBackground(new java.awt.Color(0, 0, 0));
        panelOpciones.setOpaque(false);

        bNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/add_32.png"))); // NOI18N
        bNuevo.setText("Nuevo");
        bNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bNuevoActionPerformed(evt);
            }
        });

        bEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/file_edit_32.png"))); // NOI18N
        bEditar.setText("Editar");

        bBusqueda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/search_08_32.png"))); // NOI18N
        bBusqueda.setText("Buscar");
        bBusqueda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bBusquedaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelOpcionesLayout = new javax.swing.GroupLayout(panelOpciones);
        panelOpciones.setLayout(panelOpcionesLayout);
        panelOpcionesLayout.setHorizontalGroup(
            panelOpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelOpcionesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelOpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(bEditar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(bNuevo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(bBusqueda, javax.swing.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE))
                .addContainerGap(50, Short.MAX_VALUE))
        );
        panelOpcionesLayout.setVerticalGroup(
            panelOpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelOpcionesLayout.createSequentialGroup()
                .addGap(51, 51, 51)
                .addComponent(bNuevo, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(bEditar, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(bBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(109, Short.MAX_VALUE))
        );

        panelOpciones.setBounds(20, 150, 200, 320);
        contenedor.add(panelOpciones, javax.swing.JLayeredPane.DEFAULT_LAYER);
        panelOpciones.getAccessibleContext().setAccessibleName("panelOp");
        panelOpciones.getAccessibleContext().setAccessibleParent(this);

        lNombre.setFont(new java.awt.Font("Droid Serif", 1, 18)); // NOI18N
        lNombre.setBounds(390, 20, 280, 40);
        contenedor.add(lNombre, javax.swing.JLayeredPane.DEFAULT_LAYER);
        lImagen.setBounds(560, 170, 140, 130);
        contenedor.add(lImagen, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jToolBar1.setRollover(true);

        jPanel1.setBackground(new java.awt.Color(0, 0, 0));

        bClientes.setFont(new java.awt.Font("Lucida Bright", 1, 14)); // NOI18N
        bClientes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/customer_male_light_24.png"))); // NOI18N
        bClientes.setText("Clientes");
        bClientes.setToolTipText("Administración Clientes");
        bClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bClientesActionPerformed(evt);
            }
        });

        bProv.setFont(new java.awt.Font("Lucida Bright", 1, 14)); // NOI18N
        bProv.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/group4_meeting_light_24.png"))); // NOI18N
        bProv.setText("Proveedores");
        bProv.setToolTipText(" Manejo de Proveedores");
        bProv.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bProvActionPerformed(evt);
            }
        });

        bVentas.setFont(new java.awt.Font("Lucida Bright", 1, 14)); // NOI18N
        bVentas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/cash_register_32.png"))); // NOI18N
        bVentas.setText("Ventas");
        bVentas.setToolTipText("Realizar nueva transacción");
        bVentas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bVentasActionPerformed(evt);
            }
        });

        bProductos.setFont(new java.awt.Font("Lucida Bright", 1, 14)); // NOI18N
        bProductos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/invoice_24.png"))); // NOI18N
        bProductos.setText("Inventario");
        bProductos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bProductosActionPerformed(evt);
            }
        });

        bUsuario.setFont(new java.awt.Font("Lucida Bright", 1, 14)); // NOI18N
        bUsuario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/child_male_light_24.png"))); // NOI18N
        bUsuario.setText("Usuario");
        bUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bUsuarioActionPerformed(evt);
            }
        });

        jButton2.setFont(new java.awt.Font("Lucida Bright", 1, 14)); // NOI18N
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/shopping_cart_32.png"))); // NOI18N
        jButton2.setText("Compras");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(bProductos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(bVentas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(bUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(bClientes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(bProv, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(52, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(164, 164, 164)
                .addComponent(bVentas, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(bClientes, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24)
                .addComponent(bProv, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(bProductos, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(bUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(contenedor, javax.swing.GroupLayout.DEFAULT_SIZE, 761, Short.MAX_VALUE)
                .addGap(6, 6, 6))
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(contenedor, javax.swing.GroupLayout.DEFAULT_SIZE, 667, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bUsuarioActionPerformed
        if(opcion == 10){
       
        contenedor.getSelectedFrame().dispose();
        panelOpciones.setVisible(true);
        lNombre.setText("USUARIO");
        lImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/child_male_light_128.png")));
        
        opcion = 5;
       }
       else{
        panelOpciones.setVisible(true);
        opcion = 5;
        lNombre.setText("USUARIO");
        lImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/child_male_light_128.png")));
       }
        
    }//GEN-LAST:event_bUsuarioActionPerformed

    private void bProvActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bProvActionPerformed
       if(opcion == 10){
       
        contenedor.getSelectedFrame().dispose();
        panelOpciones.setVisible(true);
        lNombre.setText("PROVEEDORES");
        lImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/group4_meeting_light_128.png")));
        opcion = 3;
       }
       else{
        panelOpciones.setVisible(true);
        lNombre.setText("PROVEEDORES");
        opcion = 3;
        lImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/group4_meeting_light_128.png")));
       }
        
    }//GEN-LAST:event_bProvActionPerformed

    private void bClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bClientesActionPerformed
       if(opcion == 10){
        contenedor.getSelectedFrame().dispose();
        panelOpciones.setVisible(true);
        lNombre.setText("CLIENTES");
        lImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/customer_male_light_128.png")));
        
        opcion = 2;
       }
       else{
        panelOpciones.setVisible(true);
        lNombre.setText("CLIENTES");
        lImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/customer_male_light_128.png")));
        opcion = 2;
       }
        
       
    }//GEN-LAST:event_bClientesActionPerformed

    private void bVentasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bVentasActionPerformed
       if(opcion == 10){
        contenedor.getSelectedFrame().dispose();
        panelOpciones.setVisible(true);
        lNombre.setText("VENTAS");
        opcion = 1;
       }
       else{
        panelOpciones.setVisible(true);
        lNombre.setText("VENTAS");
        opcion = 1;
       }
    }//GEN-LAST:event_bVentasActionPerformed

    private void bProductosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bProductosActionPerformed
        panelOpciones.setVisible(true);
        opcion = 4;
    }//GEN-LAST:event_bProductosActionPerformed

    private void bNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bNuevoActionPerformed
        if(opcion == 1){
            Ventas v = new Ventas();
            contenedor.add(v);
            v.show();
            v.setSize(contenedor.getSize());
            opcion = 10;
        }
        if (opcion == 2){
            Clientes c = new Clientes(1);
            contenedor.add(c);
            c.show();
            c.setSize(contenedor.getSize());
            opcion = 10;
            System.out.println(opcion);
        }
        if(opcion == 3){
            Proveedores p = new Proveedores();
            contenedor.add(p);
            p.show();
            p.setSize(contenedor.getSize());
            opcion = 10;
        }
        if(opcion == 4){
            Productos pr = new Productos();
            contenedor.add(pr);
            pr.show();
            pr.setSize(contenedor.getSize());
            opcion = 10;
            
        }
        if(opcion == 5){
            Usuarios u = new Usuarios();
            contenedor.add(u);
            u.show();
            u.setSize(contenedor.getSize());
            opcion = 10;
        }
    }//GEN-LAST:event_bNuevoActionPerformed

    private void bBusquedaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bBusquedaActionPerformed
        if(opcion == 1){
//            Ventas v = new Ventas();
//            contenedor.add(v);
//            v.show();
//            v.setSize(contenedor.getSize());
//            opcion = 10;
        }
        if (opcion == 2){
            BusquedaCliente c = new BusquedaCliente();
            contenedor.add(c);
            c.show();
            c.setSize(contenedor.getSize());
            opcion = 10;
            System.out.println(opcion);
        }
        if(opcion == 3){
            BusquedaProveedor p = new BusquedaProveedor();
            contenedor.add(p);
            p.show();
            p.setSize(contenedor.getSize());
            opcion = 10;
        }
        if(opcion == 4){
            BuscarProducto pr = new BuscarProducto();
            contenedor.add(pr);
            pr.show();
            pr.setSize(contenedor.getSize());
            opcion = 10;
            
        }
        if(opcion == 5){
            Usuarios u = new Usuarios();
            contenedor.add(u);
            u.show();
            u.setSize(contenedor.getSize());
            opcion = 10;
        }
    }//GEN-LAST:event_bBusquedaActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        FacturaCompra fcompra = new FacturaCompra();
        contenedor.add(fcompra);
        fcompra.show();
        fcompra.setSize(contenedor.getSize());
    }//GEN-LAST:event_jButton2ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Alternativa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Alternativa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Alternativa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Alternativa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Alternativa().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bBusqueda;
    private javax.swing.JButton bClientes;
    private javax.swing.JButton bEditar;
    private javax.swing.JButton bNuevo;
    private javax.swing.JButton bProductos;
    private javax.swing.JButton bProv;
    private javax.swing.JButton bUsuario;
    private javax.swing.JButton bVentas;
    private javax.swing.JDesktopPane contenedor;
    private javax.swing.JButton jButton2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JLabel lImagen;
    private javax.swing.JLabel lNombre;
    private javax.swing.JPanel panelOpciones;
    // End of variables declaration//GEN-END:variables
}
